﻿using System;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace NTmdb.TestProject
{
    /// <summary>
    ///     This is a test class for TmdbCreateMovieListResponseTest and is intended
    ///     to contain all TmdbCreateMovieListResponseTest Unit Tests
    /// </summary>
    [TestClass]
    public class TmdbCreateMovieListResponseTest
    {
        /// <summary>
        ///     A test for TmdbCreateMovieListResponse Constructor
        /// </summary>
        [TestMethod]
        public void TmdbCreateMovieListResponseConstructorTest()
        {
            var target = new TmdbCreateMovieListResponse();
            Assert.IsNotNull( target );
        }

        /// <summary>
        ///     A test for ListId
        /// </summary>
        [TestMethod]
        public void ListIdTest()
        {
            var target = new TmdbCreateMovieListResponse();
            string expected = Guid.NewGuid().ToString();
            target.ListId = expected;
            string actual = target.ListId;
            Assert.AreEqual( expected, actual );
        }

        /// <summary>
        ///     A test for Serialize & Deserialize
        /// </summary>
        [TestMethod]
        public async Task SerializeDeserializeTest()
        {
            var target = new TmdbCreateMovieListResponse
                {
                    ListId = Guid.NewGuid().ToString(),
                    StatusMessage = Guid.NewGuid().ToString(),
                    StatusCode = new Random().Next( 0, Int32.MaxValue )
                };
            var json = await target.Serialize();
            var actualJson =
                String.Format(
                    "{0}\"list_id\":\"{1}\",\"status_code\":{2},\"status_message\":\"{3}\"{4}",
                    "{", target.ListId, target.StatusCode, target.StatusMessage, "}" );
            Assert.AreEqual( json, actualJson );

            var actual = await target.DeserializeJson<TmdbCreateMovieListResponse>( json );
            Assert.AreEqual( target.ListId, actual.ListId );
            Assert.AreEqual(target.StatusMessage, actual.StatusMessage);
            Assert.AreEqual(target.StatusCode, actual.StatusCode);
        }
    }
}
